import {reactive} from "vue";
import {useRouter} from "vue-router";

const state = reactive({
    isLogin: false,
    token: ""
});

const methods =  {
    login(token) {
        state.isLogin = true
        state.token = token
        localStorage.setItem("token", token)
    },
    exit(router) {
        state.isLogin = false
        state.token = ""
        localStorage.clear("token")
        router.push({
            name: 'login',
        })
    }
}

export default {state, methods}